<template>
  <div class="list">
    <div class="list1" v-for="(v,i) in arr1" :key="i" @click="listdetails(v.id)">
      <img class="img" :src="v.img"/>
      <div class="text">
        <p>{{v.title}}</p>
        <p>{{v.content}}</p>
        <span>{{v.title1}}</span>
        <span>{{v.title2}}</span>
        <p>${{v.price}}</p>
        <img :src="v.imga" alt="" class="imga">
        <span>{{v.pingjia}}</span> | <span>100%好评</span>
        <p>{{$route.params.xiaoyu}}</p>
      </div>
    </div>
  </div>
</template>

<script>
import { list } from "@/api/classifyapi.js";
export default {
  data() {
    return {
      arr: [],
      arr1:[],
    };
  },
  methods: {
    listdetails(val){
        // console.log(val)
        // let aa=this.$route.params.xiaoyu;
        this.$router.push({name:"Listdetails",params:{xiaoyuyu:val}})
    }
  },
  mounted() {
    list().then((ok) => {
      console.log("listb",ok.data.data);
        //过滤器
         this.arr = ok.data.data.filter(v=> {
        if (v.id == this.$route.params.xiaoyu) {
          return v;
        }
      });
      // console.log(this.arr);
      this.arr1=this.arr[0].data;
      // console.log(this.arr1)
      //将数据存到sessionStorage中
      sessionStorage.setItem("data",JSON.stringify(this.arr))

    });
  },
};
</script>

<style scoped>
.list1 {
  width: 100%;
  height: 100%;
  display: flex;
}
.img {
  width: 50%;
  width: 1.26rem;
  height: 1.26rem;
  padding: 0.00rem 0.10rem;
  /* background: red; */
  margin-bottom: 0.05rem;
}
.imga{
  width: 0.29rem;
  height:0.16rem;
  display: block;
}
.text {
  width: 70%;
  height: 1.46rem;
  /* background: chartreuse; */
}
p:nth-of-type(1) {
  color: #333;
  font-size: 0.14rem;
}
p:nth-of-type(2) {
  color: #888;
  font-size: 0.12rem;
}

span:nth-of-type(1) {
  color: #b7b7b7;
  background: #f4f4f4;
  border-radius: 0.10rem;
  margin-right: 0.10rem;
}
span:nth-of-type(2) {
  color: #b7b7b7;
  background: #f4f4f4;
}
span:nth-of-type(3) {
  color: rgb(136, 136, 136);
}
span:nth-of-type(4) {
  color: rgb(136, 136, 136);
}
</style>

